﻿using System;
using System.Web.Mvc;
using SimpleServiceBus.EndpointManagement.Wcf.Contracts.Data;

namespace SimpleServiceBus.EndpointMonitor.Web.Helpers
{
    public static class SsbHtmlHelperExtensions
    {
        public static string EndpointStatusImage(this HtmlHelper helper,ManagedEndpointContract endpoint)
        {
            if (endpoint == null)
                return string.Empty;

            var url = new UrlHelper(helper.ViewContext.RequestContext);

            return "<img title='" + endpoint.StatusNote + "' src='" + url.EndpointImage(endpoint) +
                   "'/>";
                
        }

        public static string EndpointDisplayName(this ManagedEndpointContract endpoint)
        {
            if (endpoint.Name == null || endpoint.Name.Trim() == String.Empty)
                return endpoint.EndpointID;
            return endpoint.Name;
        }
    }
}
